package com.fm.webreader.html;

import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;

public class BasicJsoupFilter implements JsoupFilter {
	@Override
	public boolean isTable(final Element e) {
		if (e.select(">*>tr").size() <= 1) {
			return false;
		}
		Elements head = e.select(">*>tr").first().select(">td,th");
		switch (head.size()) {
			case 0:
				return false;
			case 1:
				String colspan = head.first().attr("colspan");
				if (colspan.isEmpty() || colspan.equals("1") || head.first().text().length() > 127) {
					return false;
				}
			default:
				return true;
		}
	}

	@Override
	public boolean isImage(final Element e) {
		return false;
	}
}
